﻿using GDGeek;
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MrPP.iot.Guide
{
    public class GuideManager : GDGeek.Singleton<GuideManager>
    {
        [SerializeField]
        private GuideHead _head;
        private GuideTarget target_;

        public GuideTarget target {  
            get {
                return target_;
            
            } 
            set {
                target_ = value;

                refresh();
            }
        }

        public void Start() {
            _head.transform.SetParent(CameraCache.Main.transform, false);
            _head.transform.localPosition = Vector3.zero;
            _head.transform.localRotation = Quaternion.identity;
        }

        public void OnDestroy() {
            if (_head != null) {
                GameObject.DestroyImmediate(_head);
            }  
            
        }
        private void refresh()
        {
            if (_head != null) {
                _head.lookAt(target_);
            }
            
        }

    }
}